package com.wnhz.work.yz.fragment;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bumptech.glide.Glide;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.wnhz.work.yz.BaseActivity;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.activity.EntiretyBathroom2Activity;
import com.wnhz.work.yz.bean.BathBean;
import com.wnhz.work.yz.view.RoundImageView;

import org.xutils.image.ImageOptions;

/**
 * A simple {@link Fragment} subclass.
 * ---整体卫浴1级页面
 */
public class EntiretyBathroomFragment extends Fragment implements View.OnClickListener {
    private View view;
    private RoundImageView img;
    //  private List<BathBean> bathList = new ArrayList<>();
    private BathBean bath = new BathBean();
    private static final String TAG = "EntiretyBathroomFragmen";
    private BaseActivity activity;
    public void setBath(BathBean bath) {
        this.bath = bath;
    }

    ImageOptions options = new ImageOptions.Builder()
            //设置加载过程中的图片
            //  .setLoadingDrawableId(R.mipmap.img_yushihaoshite)
            //设置加载失败后的图片
            // .setFailureDrawableId(R.mipmap.img_yushihaoshite)
            //设置使用缓存
            .setUseMemCache(true)
            //设置显示圆形图片
            .setCircular(false)
            .setRadius(8)
            //设置支持gif
            .setIgnoreGif(false).build();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_entirety_bathroom, container, false);
        activity = (BaseActivity) getActivity();
        initView();
        return view;
    }

    private void initView() {
        view.findViewById(R.id.view_click).setOnClickListener(this);
        img = (RoundImageView) view.findViewById(R.id.img);
       // ImageLoadUrl.downloadImgByUrl(bath.getPic(), 100 * 100, img);
//        ImageLoader.getInstance().displayImage(bath.getPic(),img);
        Glide.with(activity).load(bath.getPic()).into(img);
        //x.image().bind(img, bath.getPic());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.view_click:
                Intent intent = new Intent(getActivity(), EntiretyBathroom2Activity.class);
                intent.putExtra("cateId", bath.getCateid());
                intent.putExtra("titles", bath.getTitle());
                Log.i(TAG, "onClick:===== " + bath.getCateid());
                startActivity(intent);
                break;

            default:
                break;
        }
    }


}
